<template>
  <ContentWrap>
      <!-- 搜索工作栏 -->
      <el-form
        class="-mb-15px"
        :model="queryParams"
        ref="queryFormRef"
        :inline="true"
        label-width="100px"
      >
        <el-form-item label="订单编号" prop="orderCode">
          <el-input
            v-model="queryParams.orderCode"
            placeholder="请输入订单编号"
            clearable
            class="!w-240px"
            @keyup.enter="handleQuery"
          />
        </el-form-item>
        <!-- <el-form-item label="织板编码" prop="materialCode">
          <el-input
            v-model="queryParams.materialCode"
            placeholder="请输入织板编码"
            clearable
            class="!w-240px"
            @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item label="箱码" prop="cartonCode">
          <el-input
            v-model="queryParams.cartonCode"
            placeholder="请输入箱码"
            clearable
            class="!w-240px"
            @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item label="型号" prop="type">
          <el-input
            v-model="queryParams.type"
            placeholder="请输入型号"
            clearable
            class="!w-240px"
            @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item label="供应商编码" prop="supplierId">
          <el-input
            v-model="queryParams.supplierId"
            placeholder="请输入供应商编码"
            clearable
            class="!w-240px"
            @keyup.enter="handleQuery"
          />
        </el-form-item>

        <el-form-item label="出库单日期" prop="dateReq">
          <el-date-picker
            v-model="queryParams.dateReq"
            value-format="YYYY-MM-DD"
            type="daterange"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            class="!w-240px"
          />
        </el-form-item> -->
        <el-form-item>
          <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
          <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
        </el-form-item>
      </el-form>
    </ContentWrap>
  <!-- 列表 -->
  <ContentWrap>
      <el-table v-loading="loading" :data="list">
        <el-table-column type="index" label="序号" align="center" width="55" />
        <el-table-column label="订单编号" align="center" prop="orderCode" />
        <el-table-column label="出库单号" align="center" prop="exCode" />
        <el-table-column label="操作时间" align="center" prop="operatingTime" />
        <!-- <el-table-column label="订单状态" align="center" prop="exStatus" /> -->
        <!-- <el-table-column label="出库时间" align="center" prop="deliveryTime" />
        <el-table-column label="织板编码" align="center" prop="materialCode" />
        <el-table-column label="批次号" align="center" prop="batchCode" />
        <el-table-column label="箱码" align="center" prop="cartonCode" />
        <el-table-column label="供应商编号" align="center" prop="supplierId" />
        <el-table-column label="供应商" align="center" prop="supplierName" />
        <el-table-column label="成品型号" align="center" prop="type" /> -->
        <el-table-column label="操作" align="center" width="160">
          <template #default="scope">
            <div class="flex items-center justify-center">
              <el-button
                type="primary"
                link
                @click="openDetail(scope.row.exCode)"
              >查看
              </el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <Pagination
        :total="total"
        v-model:page="queryParams.pageNo"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
      />
    </ContentWrap>
    <!-- 查看对话框 -->
    <maOutboundDetail ref="formRef" @success="getList" />
  </template>
  
  <script lang="ts" setup>
  import * as maOutboundReportApi from '@/api/hcxly/materialOutboundReport/Index'
  import maOutboundDetail from './maOutboundDetail.vue'
  
  defineOptions({ name: 'materialOutboundReport' })
  
  const message = useMessage() // 消息弹窗
  const { t } = useI18n() // 国际化
  
  const loading = ref(true) // 列表的加载中
  const total = ref(0) // 列表的总页数
  const list = ref([]) // 列表的数据

  const queryParams = reactive({
    pageNo: 1,
    pageSize: 10,
    orderCode: undefined,
    orderDateReq: [],
    supplierId : '',
    cartonCode : '',
    type : '',
    materialCode : ''
  })
  const queryFormRef = ref() // 搜索的表单
  const exportLoading = ref(false) // 导出的加载中
  
  /** 查询列表 */
  const getList = async () => {
    loading.value = true
    try {
      const data = await maOutboundReportApi.getmaOutboundReport(queryParams)
      console.log(data)
      list.value = data.list
      total.value = data.total
    } finally {
      loading.value = false
    }
  }
  
  /** 搜索按钮操作 */
  const handleQuery = () => {
    queryParams.pageNo = 1
    getList()
  }
  
  /** 重置按钮操作 */
  const resetQuery = () => {
    queryFormRef.value.resetFields()
    handleQuery()
  }

  /** 初始化 **/
  onMounted(() => {
    getList()
  })
  
    /** 查看详情操作 */
    const formRef = ref()
  const openDetail = (id: string) => {
    console.log(id)
    formRef.value.open(id)
  }
  </script>
